<style>
.btn-primary {
    color: #fff;
    background-color: #337ab7;
    padding: 4px 12px !important;
    margin-bottom: 5px !important;
    margin-left: 10px;
    border-color: #2e6da4;
}
.searchType{
	text-align: left;
}

.searchType li span{
	margin-left: 40px;
}

.searchDetail{
	padding:15px 25px;
}

.reset{
	margin-left:10px;
	display: inline-block;
    line-height: 30px;
    color: #fff ;
    height: 30px;
    padding: 0 15px;
    border-radius: 3px;
    font-size: 14px;
    margin-right: 10px;
    min-width: 55px;
    text-align: center;
    cursor: pointer;
    background: #2e4158;
    margin: 10px 0;
}

 .btn-default {
    color: #333 !important;
    background-color: #fff !important;
    border-color: #ccc;
}
.ivu-input{
	width:100px;
}
</style>

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!--下级交易明细新页面 -->
<section data-v-c2f0218a="" class="main-content subTransitionNew view">

	<div data-v-01cabcb6="" class="userTitle mgb10">下级交易明细</div>
	<div data-v-01cabcb6="" class="userMain mgb10">
		<ul data-v-01cabcb6="" class="todayView mgb10"
			style="text-align: left;">
			<em data-v-01cabcb6="">账号：</em>
			<input data-v-01cabcb6="" type="text" placeholder="下级交易查询"
				class="userInput">&nbsp;
			<a data-v-01cabcb6="" class="submitBtn">搜索</a>
			<a data-v-b879b2dc="" class="reset">重置</a>
		</ul>
		<ul data-v-157ea3ee="" data-v-01cabcb6="" class="searchType">
			<!-- <li data-v-157ea3ee=""><span data-v-157ea3ee="">摘要：</span> 
			<ins data-v-157ea3ee="" class="selectIcon">
					<div data-v-157ea3ee="" class="title">
						 <select data-v-157ea3ee="" class="userSelect">
							<option data-v-157ea3ee="" value="0">账户明细</option>
							<option data-v-157ea3ee="" value="1">提现记录</option>
							<option data-v-157ea3ee="" value="2">充值记录</option>
						</select>
					</div>
					<em data-v-157ea3ee=""></em>
				</ins>
			</li> -->
			<li data-v-157ea3ee="" class="_time"><span data-v-157ea3ee="">时间：
					<a data-v-157ea3ee="" class="userSearch time active">今天</a>
					<a data-v-157ea3ee="" class="userSearch time ">昨天</a>
					<a data-v-157ea3ee="" class="userSearch time ">七天</a>
					<!-- <input type="text" id="date1" placeholder="开始时间" value="" lay-key="" class="ivu-input layer-date" readonly="readonly">
					<span style="margin: 0 10px;">至</span>
					<input type="text" id="date2" placeholder="结束时间" value="" lay-key="" class="ivu-input layer-date" readonly="readonly">
					<button class="btn btn-primary">确定</button> -->
			</span></li>
			<li data-v-157ea3ee="" class="_state"><span data-v-157ea3ee="">
					状态： <a data-v-157ea3ee="" class="userSearch time active">账户明细</a>
					<a data-v-157ea3ee="" class="userSearch time ">充值记录</a>
					<a data-v-157ea3ee="" class="userSearch time ">提现记录</a> 
					
			</span></li>
		</ul>
		<div data-v-01cabcb6="" class="searchDetail">
			<table  class="class-tableDataTable class-table-needClick display table table-striped table-bordered table-hover"  id="transactionRecords">
				
			</table>
		</div>
		<div data-v-01cabcb6="" class="userTip mgt15">
			<p data-v-01cabcb6="">
				<i data-v-01cabcb6=""></i>温馨提示：交易明细最多只保留7天。
			</p>
		</div>
	</div>

</section>
<script type="text/javascript">
	/* layui.use('laydate', function() { //layui时间插件
		 laydate= layui.laydate;
		laydate.render({
			elem: '#date1'
		});
		laydate.render({
			elem: '#date2'
		});
	}); */
	var startTime =   GetDateStr(0) ;//开始时间
	var endTime=  GetDateStr(0);//结束时间
	var cName="";
	var subName="";
	var dataTable;
	var state=0;/*默认值传0  0-账户明细     1-提现记录   2-充值记录*/
	 var columns=[
			{title:"用户名","data": "huiyuanzh","className":" huiyuanzh-td"},
			{title:"变动类型","data": "bdtype", "className": "bdtype-td"},
			{title:"变动前金额","data": "bdqjine", "className": "bdqjine-td"},
			{title:"变动金额", "data": "bdjine", "className": "bdjine-td"},
			{title:"变动后金额","data": "bdhjine", "className": "bdhjine-td"},
			{title:"时间","data": "createtime", "className": "createtime-td"},
		];
	function dataTable01(){
		dataTable=$("#transactionRecords").DataTable({
			"bProcessing" : false, 
			"bServerSide" : true,
			 "bPaginate" : true, 
			"sAjaxSource" : "/agencyCenter/subordinatePipeline.do",
			"fnServerData" : retrieveData, 
			"destroy":true,
		       "bLengthChange": true,      
		      "bSort": false,
		      "bAutoWidth": false,
		      /* 'aLengthMenu':[5],  */
		       "searching": false,  
		       "pagingType": "full",
		       "dom": "t<'tableinfo'i<'tableSearch'p>l>",  
		       "language": {
		             "lengthMenu": "每页显示 _MENU_ 条记录",     
		             "zeroRecords": "没有检索到数据",     
		            "sInfo": "当前显示 _START_ 到 _END_ 条，共 _TOTAL_ 条记录",   
		            "info": "没有数据",  
		            "oPaginate": {     
		                "sFirst": "首页",     
		                "sPrevious": "前一页",     
		                "sNext": "后一页",     
		                "sLast": "尾页"    
		          	},
		            "search":"",
		            "searchPlaceholder": "请输入关键字",
		            "infoFiltered":   "(从  _MAX_ 记录中搜索出结果)",
		            "infoEmpty":      "没有找到匹配的信息",
		         },  
		         "columnDefs": [{"defaultContent": "",
                      "targets": "_all"}],
                      "columns":columns,
		});
		function retrieveData(sSource, aoData, fnCallback) {
			$.ajax({
				url : sSource,
				data : {
					"pageCount":aoData[0].value,
					"startIndex":aoData[3].value,
					"lineCount":aoData[4].value,
					"state":state,
					"name":$(".userInput").val(),
					"cname":subName,
					"date1":startTime,
					"date2":endTime,
				},
				type : 'post',
				dataType : 'json',
				async : false,
				success : function(result) { 
					var newJson = result.aaData;
					if(newJson==""){
						if($(".userInput").val()!=""){
							layer.alert("没用这个下级用户,请重新输入");
							$(".userInput").val("");
							return;
						}
					}
					for (var i = 0; i < newJson.length; i++) {
	         			 var item = newJson[i];
	         			 if(item.bdqjine!=undefined){
	         				item.bdqjine+="元" 
	         			 }
	         			if(item.bdjine!=undefined){
	         				item.bdjine+="元" 
	         			 }
	         			if(item.bdhjine!=undefined){
	         				item.bdhjine+="元" 
	         			 }
	         			if(item.fukuanje!=undefined){
	         				item.fukuanje+="元" 
	         			 }
	        		 }
					
	        		result.aaData=newJson;
					fnCallback(result);
				},
				error : function(msg) {
				}
			});
		};
	}
	dataTable01();
	
	/* 账户明细，提现记录和充值记录之间的切换 */
 	$("._state a").on("click",function(){
		$(this).addClass("active");
		$(this).siblings().removeClass("active");
		var index=$(this).index();
		if(index==0){
			state=0;
			columns=[
				{title:"用户名","data": "huiyuanzh","className":" huiyuanzh-td"},
				{title:"变动类型","data": "bdtype", "className": "bdtype-td"},
				{title:"变动前金额","data": "bdqjine", "className": "bdqjine-td"},
				{title:"变动金额", "data": "bdjine", "className": "bdjine-td"},
				{title:"变动后金额","data": "bdhjine", "className": "bdhjine-td"},
				{title:"时间","data": "createtime", "className": "createtime-td"},
			];
		}else if(index==1){
			state=2;
			columns=[
				{title:"用户名","data": "name","className":" name-td"},
				{title:"充值金额","data": "fukuanje", "className": "fukuanje-td"},
				{title:"充值方式","data": "type", "className": "type-td"},
				{title:"状态","data": "state", "className": "state-td"},
				{title:"申请时间","data": "sqtime", "className": "sqtime-td"},
			];
		}else if(index==2){
			state=1;
			columns=[
				{title:"用户名","data": "name","className":" name-td"},
				{title:"提现金额","data": "tikuanje", "className": "fukuanje-td"},
				{title:"状态","data": "state", "className": "state-td"},
				{title:"申请时间","data": "sqtime", "className": "sqtime-td"},
			];
			
		}
		dataTable.destroy();
		dataTable.clear();
		$("#transactionRecords").empty();
		dataTable01();
	});
	
	/* 时间查询 */
	$("	._time a").on("click",function(){
		$(this).addClass("active");
		$(this).siblings().removeClass("active");
		var index=$(this).index();
		if(index==0){
			startTime=GetDateStr(0)
		}else if(index==1){
			startTime=GetDateStr(1)	
		}else if(index==2){
			startTime=GetDateStr(7)
		}
		dataTable.destroy();
		dataTable.clear();
		$("#transactionRecords").empty();
		dataTable01();
	});
	
	/* 搜索查询 */
	$(".todayView .submitBtn").on("click",function(){
		if($(".userInput").val()==""){
			return;
		}
		dataTable01();
	});
	
	/* 重置 */
	$(".todayView .reset").on("click",function(){
		$(".userInput").val("");
		startTime=GetDateStr(0)
		state=0;
		$("._time a").removeClass("active");
		$("._time a").eq(0).addClass("active");
		$("._state a").removeClass("active");
		$("._state a").eq(0).addClass("active");
		columns=[
			{title:"用户名","data": "huiyuanzh","className":" huiyuanzh-td"},
			{title:"变动类型","data": "bdtype", "className": "bdtype-td"},
			{title:"变动前金额","data": "bdqjine", "className": "bdqjine-td"},
			{title:"变动金额", "data": "bdjine", "className": "bdjine-td"},
			{title:"变动后金额","data": "bdhjine", "className": "bdhjine-td"},
			{title:"时间","data": "createtime", "className": "createtime-td"},
		];
		dataTable.destroy();
		dataTable.clear();
		$("#transactionRecords").empty();
		dataTable01();
	});
	
</script>
